home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
1_0-2
/
D2R_FOLD
/
D2R_DELE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1986-11-08
|
2KB
|
64 lines
#include "::MacIncludes:DeviceMgr.h"
#include "::MacIncludes:EventMgr.h"
#include "::MacIncludes:FontMgr.h"
#include "::MacIncludes:WindowMgr.h"
#include "::MacIncludes:DialogMgr.h"
#include "::MacIncludes:ControlMgr.h"
#include "::MacIncludes:MenuMgr.h"
#include "::MacIncludes:MemoryMgr.h"
#include "::MacIncludes:StdFilePkg.h"
#include "::MacIncludes:SegmentLdr.h"
#define NULL 0L
int firstTime = TRUE;
pascal int mydlgHook(theItem, theDialog) /* dlgHook to make 'Delete' button */
int theItem;
DialogPtr theDialog;
{
int theType;
Handle theItemH;
Rect theBox;
static Str255 OPEN="\pDelete";
ControlHandle whichControl;
if (firstTime) /* Not very elegant */
{
GetDItem(theDialog, getOpen, &theType, &theItemH, &theBox);
SetCTitle(theItemH, OPEN);
SetDItem(theDialog, getOpen, theType, theItemH, &theBox);
firstTime = FALSE;
}
return( theItem );
}
deletefile() /* Puts up Standard File dialog and allows you to delete a file */
{
SFReply reply;
Point pt;
char volname[30];
int tint,
errCode,
result;
long tlong;
InitCursor();
SetPt(&pt, (512-348)/2, (342-200)/2);
firstTime = TRUE;
SFGetFile(pt, "\p", NULL, -1, NULL, &mydlgHook, &reply);
if (reply.good)
{
GetVInfo(reply.vRefNum, volname, &tint, &tlong);
if (PromptAlert("\pAre you sure you want to delete '",reply.fName,"\p' ?",NULL))
{
errCode = FSDelete(reply.fName,reply.vRefNum); /* Bye, Bye file!! */
if (errCode != noErr)
ErrorAlert("\pSorry - can't delete that file!");
FlushVol(NULL,reply.vRefNum); /* Must do this */
}
}
}